package mytest.wd;

import com.alibaba.fastjson.JSONObject;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;

import java.util.Map;

public class TestMap {

    public static void main(String[] args) {
        String s = "{\n" +
                "    \"bg_user_gid\": null,\n" +
                "    \"biz_user_gid\": \"6041e62d-f189-4a44-969a-4bc12e82304a\",\n" +
                "    \"ch\": null,\n" +
                "    \"channel\": \"alend\",\n" +
                "    \"channelSub\": \"3\",\n" +
                "    \"channelSubSpread\": \"1050120101\",\n" +
                "    \"crawlerTime\": 1723687124372,\n" +
                "    \"data_version\": \"V1.0\",\n" +
                "    \"idcardNo\": \"008663608149109271863\",\n" +
                "    \"phone\": \"8149109271\",\n" +
                "    \"platform\": \"alend\",\n" +
                "    \"realName\": null,\n" +
                "    \"recordGid\": \"f8343709-c1a5-4d42-b5a1-1f73e419\",\n" +
                "    \"report\": {\n" +
                "        \"nigcontact\": [\n" +
                "            {\n" +
                "                \"name\": \"Deji\",\n" +
                "                \"phoneNo\": \"06043821549\",\n" +
                "                \"relation\": \"4\"\n" +
                "            },\n" +
                "            {\n" +
                "                \"name\": \"Folake\",\n" +
                "                \"phoneNo\": \"08033887485\",\n" +
                "                \"relation\": \"1\"\n" +
                "            },\n" +
                "            {\n" +
                "                \"name\": \"Damilola \",\n" +
                "                \"phoneNo\": \"08167160750\",\n" +
                "                \"relation\": \"4\"\n" +
                "            }\n" +
                "        ],\n" +
                "        \"nigfacecheck\": {\n" +
                "            \"credit_living\": {\n" +
                "                \"channel\": \"alend\",\n" +
                "                \"livenessId\": \"1723687024,d0e9eefc-2b1b-43f5-8c62-74ac400be90f\",\n" +
                "                \"livenessScore\": \"100\",\n" +
                "                \"verifySource\": \"fa\"\n" +
                "            },\n" +
                "            \"face_check\": {\n" +
                "                \"address\": {},\n" +
                "                \"allValidationPassed\": false,\n" +
                "                \"businessId\": \"655c1bf28e2bbd4dd78cc411\",\n" +
                "                \"country\": \"NG\",\n" +
                "                \"createdAt\": \"2024-08-15T01:58:44.178Z\",\n" +
                "                \"dataValidation\": true,\n" +
                "                \"dateOfBirth\": \"1982-02-02\",\n" +
                "                \"firstName\": \"IMONIKHE\",\n" +
                "                \"fullDetails\": false,\n" +
                "                \"gender\": \"Male\",\n" +
                "                \"id\": \"66bd60cef7de602a3c07b730\",\n" +
                "                \"idNumber\": \"22186821202\",\n" +
                "                \"image\": \"https://starfruit-ngn.afr-nigeria.ufileos.com/9bd1b836ac9b4c0581bb7ba655209601_1723687124262_deab3b3c402f4b6e95daced1842c0a2ajpg.jpg?UCloudPublicKey=TOKEN_a59a9232-c7ac-4cab-be2b-4aad4834099a&Signature=HaO1QT128B0wwAO3MZ3gxPquvVk%3D&Expires=2039047124\",\n" +
                "                \"isConsent\": true,\n" +
                "                \"lastModifiedAt\": \"2024-08-15T01:58:44.178Z\",\n" +
                "                \"lastName\": \"AGELOISA\",\n" +
                "                \"metadata\": {\n" +
                "                    \"requestId\": \"594badc3db\"\n" +
                "                },\n" +
                "                \"middleName\": \"ONIKE\",\n" +
                "                \"mobile\": \"08030936043\",\n" +
                "                \"registrationDate\": \"Invalid date\",\n" +
                "                \"requestedAt\": \"2024-08-15T01:58:44.158Z\",\n" +
                "                \"requestedBy\": {\n" +
                "                    \"firstName\": \"API\",\n" +
                "                    \"id\": \"655c1bf28e2bbd09e58cc412\",\n" +
                "                    \"lastName\": \"User\",\n" +
                "                    \"middleName\": \"\"\n" +
                "                },\n" +
                "                \"requestedById\": \"655c1bf28e2bbd09e58cc412\",\n" +
                "                \"selfieValidation\": true,\n" +
                "                \"shouldRetrivedNin\": true,\n" +
                "                \"status\": \"found\",\n" +
                "                \"type\": \"bvn\",\n" +
                "                \"validations\": \"\"\n" +
                "            },\n" +
                "            \"liveUrl\": \"https://starfruit-ngn.afr-nigeria.ufileos.com/a6c4c62260ec47148dc1b6f0dccd3525_1723687118409_542b507d366149c6b36acf46df53de79jpg.jpg?UCloudPublicKey=TOKEN_a59a9232-c7ac-4cab-be2b-4aad4834099a&Signature=%2B5tLYTywPm4S%2BC4SFeEvNSuP9gQ%3D&Expires=2039047118\"\n" +
                "        },\n" +
                "        \"nigpersoninfo\": {\n" +
                "            \"birthday\": \"1999/03/15\",\n" +
                "            \"bvnNumber\": \"22186821202\",\n" +
                "            \"email\": \"Odofinvictor0@gmail.com\",\n" +
                "            \"gender\": \"1\",\n" +
                "            \"lastName\": \"Odofin \",\n" +
                "            \"middleName\": \"Joseph\",\n" +
                "            \"name\": \"Victor \"\n" +
                "        }\n" +
                "    },\n" +
                "    \"s_forwarder\": \"ngn-as-02a2,1723687125\",\n" +
                "    \"s_host\": \"ngn-as-02a2\",\n" +
                "    \"s_line_num\": 42,\n" +
                "    \"s_path\": \"/data/bigdata/creditreport/metric.20240815.log\",\n" +
                "    \"s_site\": \"ngn\",\n" +
                "    \"simpleCredit\": 0,\n" +
                "    \"source\": \"alend\",\n" +
                "    \"sptype\": \"user.credit.application\",\n" +
                "    \"tag\": \"spider.creditreport\",\n" +
                "    \"time\": 1723687125,\n" +
                "    \"tokenId\": \"fd624bbf24cc4e559c20c072c2629624\",\n" +
                "    \"totalNum\": 1,\n" +
                "    \"userGreyed\": false,\n" +
                "    \"workflow_gid\": \"50aedfff30c747c79cc1f9cdf66777af\"\n" +
                "}";
        String s1 = getS(s);
        System.out.println(s1);
    }

    public static String getS(String s) {
        Map<String, Object> map = JSONObject.parseObject(s);
        Map report = MapUtils.getMap(map, "report");
        Map faceCheckInfoMap= MapUtils.getMap(null, "nigfacecheck");
        Map faceCheckMap = MapUtils.getMap(faceCheckInfoMap, "face_check");
        Map validations = MapUtils.getMap(faceCheckMap, "validations");
        Map selfie = MapUtils.getMap(validations, "selfie");
        Map selfieVerification = MapUtils.getMap(selfie, "selfieVerification");
        String confidenceLevel = MapUtils.getString(selfieVerification, "confidenceLevel");
        return StringUtils.isNotBlank(confidenceLevel) ? confidenceLevel : "-99999999999979";
    }

}
